/*
 * 
 */
package fr.univtln.superplanning.api.event;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;

import fr.univtln.superplanning.api.actor.Teacher;
import fr.univtln.superplanning.api.resources.Classroom;
import fr.univtln.superplanning.api.study.Promotion;
import fr.univtln.superplanning.api.study.Teaching;

// TODO: Auto-generated Javadoc
/**
 * This class represents a course given by a teacher for students.
 * 
 * @author vincent
 * 
 */
@Entity
public class Course extends Event {

	/** Define the promotion associated to this event. */
	@OneToMany(cascade = CascadeType.ALL)
	private List<Promotion> promotions = new ArrayList<Promotion>();

	/** Define the teaching for the course */
	@JoinColumn(nullable = false)
	private Teaching teaching;

	@JoinColumn(nullable = false)
	private Teacher teacher;

	@JoinColumn(nullable = false)
	private Classroom classroom;
	
	/**
	 * Instantiates a new course.
	 */
	public Course() {
	}

	public Course(Teaching teaching, Teacher teacher, Classroom classroom) {
		super();
		this.teaching = teaching;
		this.teacher = teacher;
		this.classroom = classroom;
	}

	public Course(Teaching teaching) {
		this.teaching = teaching;
	}

	public Course(Teaching teaching, Calendar beginDateTime, int duration, EventType type) {
		this(teaching, beginDateTime, duration, type, "");
	}

	public Course(Teaching teaching, Calendar beginDateTime, int duration, EventType type,
			String comments) {
		super(beginDateTime, duration, type, comments);
		this.teaching = teaching;
	}

	public List<Promotion> getPromotions() {
		return promotions;
	}

	public void setPromotions(List<Promotion> promotions) {
		this.promotions = promotions;
	}

	public Teaching getTeaching() {
		return teaching;
	}

	public void setTeaching(Teaching teaching) {
		this.teaching = teaching;
	}

	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	/**
	 * Adds the.
	 * 
	 * @param arg0
	 *            the arg0
	 * @param arg1
	 *            the arg1
	 */
	public void add(int arg0, Promotion arg1) {
		promotions.add(arg0, arg1);
	}

	/**
	 * Adds the.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean add(Promotion arg0) {
		return promotions.add(arg0);
	}

	/**
	 * Adds the all.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean addAll(Collection<? extends Promotion> arg0) {
		return promotions.addAll(arg0);
	}

	/**
	 * Adds the all.
	 * 
	 * @param arg0
	 *            the arg0
	 * @param arg1
	 *            the arg1
	 * @return true, if successful
	 */
	public boolean addAll(int arg0, Collection<? extends Promotion> arg1) {
		return promotions.addAll(arg0, arg1);
	}

	/**
	 * Clear.
	 */
	public void clear() {
		promotions.clear();
	}

	/**
	 * Contains.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean contains(Object arg0) {
		return promotions.contains(arg0);
	}

	/**
	 * Contains all.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean containsAll(Collection<?> arg0) {
		return promotions.containsAll(arg0);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object arg0) {
		return promotions.equals(arg0);
	}

	/**
	 * Get the.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return the promotion
	 */
	public Promotion get(int arg0) {
		return promotions.get(arg0);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return promotions.hashCode();
	}

	/**
	 * Index of.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return the int
	 */
	public int indexOf(Object arg0) {
		return promotions.indexOf(arg0);
	}

	/**
	 * Checks if is empty.
	 * 
	 * @return true, if is empty
	 */
	public boolean isEmpty() {
		return promotions.isEmpty();
	}

	/**
	 * Iterator.
	 * 
	 * @return the iterator
	 */
	public Iterator<Promotion> iterator() {
		return promotions.iterator();
	}

	/**
	 * Last index of.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return the int
	 */
	public int lastIndexOf(Object arg0) {
		return promotions.lastIndexOf(arg0);
	}

	/**
	 * List iterator.
	 * 
	 * @return the list iterator
	 */
	public ListIterator<Promotion> listIterator() {
		return promotions.listIterator();
	}

	/**
	 * List iterator.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return the list iterator
	 */
	public ListIterator<Promotion> listIterator(int arg0) {
		return promotions.listIterator(arg0);
	}

	/**
	 * Remove the.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return the promotion
	 */
	public Promotion remove(int arg0) {
		return promotions.remove(arg0);
	}

	/**
	 * Remove the.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean remove(Object arg0) {
		return promotions.remove(arg0);
	}

	/**
	 * Remove the all.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean removeAll(Collection<?> arg0) {
		return promotions.removeAll(arg0);
	}

	/**
	 * Retain all.
	 * 
	 * @param arg0
	 *            the arg0
	 * @return true, if successful
	 */
	public boolean retainAll(Collection<?> arg0) {
		return promotions.retainAll(arg0);
	}

	/**
	 * Set the.
	 * 
	 * @param arg0
	 *            the arg0
	 * @param arg1
	 *            the arg1
	 * @return the promotion
	 */
	public Promotion set(int arg0, Promotion arg1) {
		return promotions.set(arg0, arg1);
	}

	/**
	 * Size.
	 * 
	 * @return the int
	 */
	public int size() {
		return promotions.size();
	}

	/**
	 * Sub list.
	 * 
	 * @param arg0
	 *            the arg0
	 * @param arg1
	 *            the arg1
	 * @return the list
	 */
	public List<Promotion> subList(int arg0, int arg1) {
		return promotions.subList(arg0, arg1);
	}

	/**
	 * To array.
	 * 
	 * @return the object[]
	 */
	public Object[] toArray() {
		return promotions.toArray();
	}

	/**
	 * To array.
	 * 
	 * @param <T>
	 *            the generic type
	 * @param arg0
	 *            the arg0
	 * @return the t[]
	 */
	public <T> T[] toArray(T[] arg0) {
		return promotions.toArray(arg0);
	}

	public void setClassroom(Classroom classroom) {
		this.classroom = classroom;
	}

	public Classroom getClassroom() {
		return classroom;
	}

}
